
local MainScene = class("MainScene", cc.load("mvc").ViewBase)

function MainScene:onCreate()
    local label = cc.Label:createWithSystemFont("点击进入物理场景", display.DEFAULT_TTF_FONT, 30)
        :addTo(self)
        :move(display.cx, display.cy)

    local function OnTouchOBOBegan(touch, event)
        return true
    end

    local function OnTouchOBOEnded(touch, event)
        local pos = touch:getLocation()
        if cc.rectContainsPoint(label:getBoundingBox(), pos) then
            local scene = import("app.views.PhysicsScene"):new()
            display.runScene(scene)
        end
    end

    local listener = cc.EventListenerTouchOneByOne:create()
    listener:registerScriptHandler(OnTouchOBOBegan, cc.Handler.EVENT_TOUCH_BEGAN)
    listener:registerScriptHandler(OnTouchOBOEnded, cc.Handler.EVENT_TOUCH_ENDED)
    local eventDispatcher = self:getEventDispatcher()
    eventDispatcher:addEventListenerWithSceneGraphPriority(listener, label)
end

return MainScene
